import { BasicColumn, FormSchema } from '@/components/Table';
import { getDeptList } from '@/modules/system/api';

export const ColumnPage: BasicColumn[] = [
  {
    title: '部门名称',
    dataIndex: 'deptName',
    align: 'left',
  },
  {
    title: '排序',
    dataIndex: 'orderNo',
  },
  {
    title: '添加时间',
    dataIndex: 'createTime',
    width: 150,
    fixed: 'right',
    customRender: ({ record }) => {
      return record.createTime?.substring(0, 16);
    },
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'deptName',
    label: '部门名称',
    component: 'Input',
    colProps: { span: 8 },
  },
];

export const FormSchemaAdd: FormSchema[] = [
  {
    field: 'deptName',
    label: '部门名称',
    component: 'Input',
    required: true,
  },
  {
    field: 'pid',
    label: '上级部门',
    component: 'ApiTreeSelect',
    componentProps: {
      api: getDeptList,
      params: { type: 'select' },
      resultField: 'list',
      labelField: 'deptName',
      valueField: 'id',
    },
    required: true,
    colProps: { span: 24 },
  },
  {
    field: 'orderNo',
    label: '排序',
    component: 'InputNumber',
    defaultValue: 1,
    required: true,
    componentProps: {
      min: 1,
    },
  },
];
